<?php
namespace app\admin\controller;

use app\common\model\ActsOrder as ActsOrderModel;

/**
 * 所有寺院项目捐款明细控制器
 * Class Act
 * @package app\index\controller
 */
class Actsorder extends Base
{
    /**
     * [index  所有寺院项目捐款列表]
     * @param
     * @return mixed|\think\response\Json
     * @author [C。]
     */
    public function index()
    {
        $param = input('param.');
        $model = new ActsOrderModel();
        $this->getPageAndSize($param);
        $map = [];
        try{
            if(!empty($param['key'])){
                if($param['key'] == 1){
                    $map['c.comname'] = $param['con'];
                }elseif($param['key'] == 3){
                    $map['o.nickname'] = $param['con'];
                }
            }

            if(!empty($param['start']) && !empty($param['end'])){
                $map['o.create_time'] = ['between',[strtotime($param['start']),strtotime($param['end'])]];
            }
            $field = 'o.id,c.comname,o.nickname,o.money,o.create_time,o.img';
            $count = $model->getCounts($map);
            $allpage = intval(ceil($count / $this->size));//总页数
            $list = $model->getlists($map,$this->from, $this->size,$field);
        } catch (\Exception $e) {
            systembug($e->getMessage(),1,'admin/actsorder/index');
            return admin_json(-1, '获取失败'.$e->getMessage());
        }
        return admin_json(1, '获取成功',[
            'count' => $count,//总记录数
            'allpage' => $allpage,  //总页数
            'list' => $list
        ]);
    }
}